package model

import (
	"github.com/zhengchalei/gadmin/framework"
)

func init() {
	framework.AutoMigrate("ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统部门'", &SysDept{})
	if framework.DB.Find(&SysDept{}).First(&SysDept{Model: framework.Model{ID: 1}}).RowsAffected == 0 {
		framework.DB.Save(&SysDept{Model: framework.Model{ID: 1}, Name: "系统部门", Remark: "系统默认部门"})
	}
}

type SysDept struct {
	framework.Model
	Name   string `json:"name" form:"name" gorm:"not null;unique;comment:部门名;"`
	Remark string `json:"remark" form:"remark" gorm:"comment:部门描述;"`
	// join
	Users []SysUser `json:"users" gorm:"foreignKey:DeptId;"`
}
